#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import plotly.express as px
import pandas as pd
import requests
import json

def get_geojson():
    """获取深圳市geojson"""
    with open('深圳市.json') as f:
        text = f.read()
    return json.loads(text)

if __name__ == "__main__":
    # 数据 （复制随书附件后运行）
    df = pd.read_clipboard(delimiter='\s+',thousands=',')
    # 获取深圳市geojson
    city = get_geojson()
    # 创建Figure 轨迹+画布
    fig = px.choropleth(df,geojson=city,locations='街道',color='交通指数',
                       featureidkey='properties.NAME',color_continuous_scale='Reds',
                       title='深圳市交通指数')
    # 去除默认的世界地图
    fig.update_geos(fitbounds="locations", visible=False)
    # 显示画布
    fig.show()
